package com.netease.examination.configuration;

import com.netease.examination.interceptor.LoginRequiredInterceptor;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

import javax.annotation.Resource;

/**
 * designed by destiny
 *
 * 将验证cookie-session一致性的拦截器注册进逻辑链路中
 *
 * @author destiny
 *         e-mail destinywk@163.com
 *         github https://github.com/DestinyWang
 *         oschina https://git.oschina.net/destinywk
 * @version JDK 1.8.0_101
 * @since 2017/3/30 11:58
 */
@Component
public class ExaminationWebConfiguration extends WebMvcConfigurerAdapter{

    @Resource
    private LoginRequiredInterceptor loginRequiredInterceptor;


    /**
     * 注册拦截器的具体方法
     *
     * @param registry  负责注册拦截器的对象
     */
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(loginRequiredInterceptor)
                .excludePathPatterns("/").addPathPatterns("/**").excludePathPatterns("/login").excludePathPatterns("/findGoodsList");
        super.addInterceptors(registry);
    }
}
